Skip to content

feat: Add async big segment store manager and async Redis adapter - #462

Merged
jsonbailey merged 12 commits into
mainfrom
jb/sdk-2729/async-big-segments
Jul 27, 2026
Merged

feat: Add async big segment store manager and async Redis adapter#462
jsonbailey merged 12 commits into
mainfrom
jb/sdk-2729/async-big-segments

Conversation

@jsonbailey

@jsonbailey jsonbailey commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

What

The async big-segments layer for the async Python SDK.

  • impl/async_big_segments.pyAsyncBigSegmentStoreManager (async twin of the sync manager: membership caching via ExpiringDict, status polling via AsyncRepeatingTask) + BigSegmentStoreStatusProviderImpl.
  • impl/integrations/redis/async_redis_big_segment_store.py — async Redis-backed AsyncBigSegmentStore (redis.asyncio).
  • integrations/__init__.py — new Redis.async_big_segment_store(...) factory (local import of the adapter, so redis stays optional).
  • async_config.pyseeded with AsyncBigSegmentsConfig only (see below).
  • Tests: testing/impl/test_async_big_segments.py (unit) + testing/integrations/test_async_redis.py (live-Redis integration, guarded by skip_database_tests).
  • pyproject.toml — the published [redis] extra floor is unchanged (>=2.10.5); only the dev/test redis dependency is bumped to >=4.2.0 so CI can exercise redis.asyncio. Async Redis support requires redis>=4.2.0, surfaced via a README note and the adapter's guarded import (a clear error if redis.asyncio is unavailable) rather than by raising the consumer-facing floor. Raising the published floor is deferred pending a team decision before the async client ships.

Note on async_config.py

AsyncBigSegmentStoreManager needs AsyncBigSegmentsConfig, which lives in async_config.py. The full AsyncConfig isn't extractable yet (it imports AsyncHook/AsyncPlugin/AsyncEventProcessor, which land in later slices), so this PR seeds async_config.py with just the self-contained AsyncBigSegmentsConfig (it depends only on the already-merged AsyncBigSegmentStore). A later slice grows the file with AsyncConfig — mirroring how the sync SDK keeps BigSegmentsConfig alongside Config in config.py.

Why

Part of the async Python SDK (epic SDK-60). Depends on the async support classes (#451) and async interfaces/store (#457), both merged.

Validation

  • uv run pytest ldclient/testing --ignore=ldclient/testing/integrations — 1033 passed, 2 skipped
  • uv run pytest ldclient/testing/impl/test_async_big_segments.py — 14 passed
  • uv run mypy ldclient — clean; isort / pycodestyle — clean
  • Redis integration tests (test_async_redis.py) require a live Redis (run in CI); properly guarded by skip_database_tests.

SDK-2729 (epic SDK-60).


Note

Medium Risk
Changes sit on the flag-evaluation path for Big Segments (incorrect membership or status can skew targeting); sync code is mostly a refactor but async behavior differs for status reads until polling completes. Marked experimental with new I/O to Redis.

Overview
Adds the experimental async Big Segments stack: AsyncBigSegmentsConfig, AsyncBigSegmentStoreManager (membership cache, background status polling via AsyncRepeatingTask, inline poll when membership runs before the first poll), and Redis.async_big_segment_store() backed by redis.asyncio.

Refactors sync big-segments code by moving BigSegmentStoreStatusProviderImpl, hashing, staleness checks, and EMPTY_MEMBERSHIP into big_segments_common.py; the sync manager now imports those helpers (behavior should match prior logic).

Documents that BigSegmentStoreStatusProvider.status is non-blocking in the async client (available=False until the first poll) vs blocking inline poll in the sync SDK. Dev dependency redis is bumped to >=4.2.0 for CI; the published [redis] extra floor is unchanged.

Reviewed by Cursor Bugbot for commit 4ac5c6c. Bugbot is set up for automated code reviews on this repo. Configure here.

Adds AsyncBigSegmentStoreManager, the async Redis-backed AsyncBigSegmentStore adapter, and Redis.async_big_segment_store(). Seeds async_config.py with the self-contained AsyncBigSegmentsConfig (the full AsyncConfig lands later). Bumps the redis dependency to >=4.2.0 (required by redis.asyncio).
Drop the max_connections=10 default (and the now-unneeded redis_opts copy) so the async store passes redis_opts straight to from_url, matching the sync store. The sync side removed this cap in #387 (it throttled connections under load); redis.asyncio otherwise defaults to an effectively-unlimited pool.
…egments_common

Both big_segments.py and async_big_segments.py defined the class identically (bar one docstring word); move it to a shared module imported by both, matching the evaluator_common/client_common pattern.
Fold _hash_for_user_key, EMPTY_MEMBERSHIP, and is_stale (as a free function) into big_segments_common, imported by both big_segments.py and async_big_segments.py.
Drop the redundant EMPTY_MEMBERSHIP class attribute and reference the
big_segments_common module constant directly instead of via self.
@jsonbailey
jsonbailey marked this pull request as ready for review July 21, 2026 16:24
@jsonbailey
jsonbailey requested a review from a team as a code owner July 21, 2026 16:24
Comment thread pyproject.toml Outdated
Comment thread ldclient/impl/async_big_segments.py Outdated
@jsonbailey
jsonbailey requested a review from keelerm84 July 27, 2026 14:05

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f236c59. Configure here.

Comment thread ldclient/impl/integrations/redis/async_redis_big_segment_store.py Outdated
@jsonbailey
jsonbailey merged commit aa492d2 into main Jul 27, 2026
15 checks passed
@jsonbailey
jsonbailey deleted the jb/sdk-2729/async-big-segments branch July 27, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants